<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_list" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 物料清单 </span>
      </div>
      <el-table :data="s_list">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="原料名称" prop="product_name">
        </el-table-column>
        <el-table-column label="规格" prop="product_norm">
        </el-table-column>
        <el-table-column label="型号" prop="product_model">
        </el-table-column>
        <el-table-column label="库存数量" prop="product_num">
        </el-table-column>
        <el-table-column label="生产占用数" prop="occupy_num">
        </el-table-column>
        <el-table-column label="需求数量" prop="need_num">
          <template slot-scope="scope">
            <el-input v-model="scope.row.need_num" />
          </template>
        </el-table-column>
        <el-table-column label="库存单位" prop="product_unit">
        </el-table-column>
        <el-table-column label="状态" prop="purchase_state">
          <template slot-scope="scope">
            {{getValueName("正常=0,已采购=1",scope.row.purchase_state)}}
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 转成生产 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="标题" prop="plan_name">
              {{t_plan.plan_title}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品名称" prop="">
              {{t_plan.product_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品规格" prop="">
              {{t_plan.morm}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品型号" prop="">
              {{t_plan.model}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品数量" prop="">
              {{t_plan.product_num}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="每天生产能力" prop="">
              {{t_plan.throughput}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            {{t_plan.throughput_unit}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="完成时间" prop="plan_produce_entry_date">
              {{getDateTimeString(t_plan,'com_time')}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="计划说明" prop="">
              {{t_plan.plan_explain}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="">
              {{t_plan.remark}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="预估生产开始时间" prop="plan_produce_begin_date">
              <el-date-picker v-model="t_plan.bug_begin_time" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产负责人" prop="">
              {{t_plan.plan_charge}}
              <el-button @click="popSelectionOfficerCurrency('','plan_charge')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="transferProductionSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/mes/produce/DetailsPlan?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
    </el-form>
    <el-dialog :visible.sync="SelectionOfficerCurrencyVisible" append-to-body>
      <SelectionOfficerCurrency v-if="SelectionOfficerCurrencyVisible" ref="SelectionOfficerCurrency" :popparams="popparams"> </SelectionOfficerCurrency>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionOfficerCurrency from "@/views/mes/autooffice/SelectionOfficerCurrency";
  export default {
    name: 'TransferProduction',
    components: {
      SelectionOfficerCurrency,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionOfficerCurrencyVisible: false,
        SelectionOfficerCurrencyValue: null,
        SelectionOfficerCurrencyDesc: null,
        vueparams: this.getVUEParams(""),
        s_list: [],
        t_plan: {
          plan_title: null,
          product_name: null,
          morm: null,
          model: null,
          product_num: null,
          throughput: null,
          throughput_unit: null,
          com_time: null,
          plan_explain: null,
          remark: null,
          bug_begin_time: null,
          plan_charge: null,
        },
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/ProductionPlanMange/transferProduction?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      transferProductionSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/ProductionPlanMange/transferProductionSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/DetailsPlan/detailsPlan?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popSelectionOfficerCurrency(desc, value) {
        this.SelectionOfficerCurrencyVisible = true;
        this.SelectionOfficerCurrencyDesc = desc;
        this.SelectionOfficerCurrencyValue = value;
      },
      closeSelectionOfficerCurrency(value, desc) {
        this.SelectionOfficerCurrencyVisible = false;
        this.$set(this.t_plan, this.SelectionOfficerCurrencyDesc, desc);
        this.$set(this.t_plan, this.SelectionOfficerCurrencyValue, value);
      },
    },
  }
</script>
